package com.onluy.framework.tools.utils;


import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.Clob;

import javax.imageio.ImageIO;

import org.apache.axis.utils.ByteArrayOutputStream;
import org.apache.commons.codec.binary.Base64;
import org.springframework.web.multipart.MultipartFile;

import sun.misc.BASE64Decoder;

public class ImageUtils { 
	
	public static void main(String[] args) throws IOException {
		
       String img = "/9j/4AAQSkZJRgABAQAAAAAAAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAAAAAAAAAQAAAAAAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAANmgAwAEAAAAAQAAANsAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIANsA2QMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTV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+CfibxJochtr+0gsninT76mW9SCQZ7q8TsjqcqwPINfmtqCrDZ20EfCtFkj1Pv617OV4NVf3tTY8DNMU4y9jAqXt+JgkVuCIFwCQDz6dPTFdLpiGO2NvCFYkDJYAng5GCRkH3GOODxmudtAPsz/hXRw/u0Rk4PHNfSW+yeDvdizWJnYh41Q9crVObSLpIywAlTv8A/qrolZiQT3FEzuIpAD0wPwNWlsxx1Rw4QWysyJuC8lWHvnj/AOvULQtfX8VtBHnPUDt357dq7o2VrNPbeamcnB69Mj/Guj8L2dqurylY1GMY46dRxTSIlfZFzwj4Fhjf7RfXLxMeVMWDgc+orvm8K6w7KI79GjRyUdlIfaR0IGe/v+NNQlY228Y6fpWxYzSs/lljjB4rRR0uC7msvhXxfLAkmk3tu8kZ3YLMhOORt4wD9SBWJqOsa9caw11NZS2l8NqSRyL0IHLKw4ZSOhH+BPPXOuavb6jFHBcOis5BAOOBjFdVJqV/cIBPMz7TgEnJAPOM/jSS0uWu511k+uahBNcWK/aYwp3iM7nVh046kH1GQO+K4v8A4SnXf7tx/wB9n/GuV8F6rqVvqV0sE8iBmyQGIHGMfzr0Tz5v71CdtBruf//Z";
       generateImage(img, "C:\\Users\\zc\\Desktop\\22.jpg");
    }
	
	private final static int BASE_WIDTH = 795;  //一人一码、一厅一码预览素材宽度
	private final static int CODE_WIDTH = 150;  //一人一码、一厅一码预览二维码宽度
	private final static int BASE_HEIGHT = 535;  //一人一码、一厅一码预览素材高度
	private final static int CODE_HEIGHT = 150; //一人一码、一厅一码预览二维码高度
	
	     
	     /**
	      * @author chenzheng
	      * 将图片转换成Base64编码
	      * @param imgFile 待处理图片
	      * @return
	      * @创建时间 2017-06-19
	      */
	     public static String getImgStr(String imgFile){
	         //将图片文件转化为字节数组字符串，并对其进行Base64编码处理   
	         InputStream in = null;
	         byte[] data = null;
	         //读取图片字节数组
	         try 
	         {
	             in = new FileInputStream(imgFile);        
	             data = new byte[in.available()];
	             in.read(data);
	             in.close();
	         } 
	         catch (IOException e) 
	         {
	             e.printStackTrace();
	         }
	         return new String(Base64.encodeBase64(data));
	     }
	     
	     public static String getImgIo(InputStream in){
	         //将图片文件转化为字节数组字符串，并对其进行Base64编码处理   
	    	 if(in == null){
	    		 return "";
	    	 }
	         byte[] data = null;
	         //读取图片字节数组
	         try 
	         {
	             data = new byte[in.available()];
	             in.read(data);
	             in.close();
	         } 
	         catch (IOException e) 
	         {
	             e.printStackTrace();
	         }finally{
	        	 if(in != null){
	        		 try {
						in.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
	        	 }
	         }
	         return new String(Base64.encodeBase64(data));
	     }
	     
	     public static String getImgFile(MultipartFile imgFile){
	         //将图片文件转化为字节数组字符串，并对其进行Base64编码处理   
	         InputStream in = null;
	         byte[] data = null;
	         //读取图片字节数组
	         try 
	         {
	             in = imgFile.getInputStream();        
	             data = new byte[in.available()];
	             in.read(data);
	             in.close();
	         } 
	         catch (IOException e) 
	         {
	             e.printStackTrace();
	         }finally{
	        	 if(in != null){
	        		 try {
						in.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
	        	 }
	         }
	         return new String(Base64.encodeBase64(data));
	     }
	     
	     /**
	      * @author chenzheng
	      * 对字节数组字符串进行Base64解码并生成图片
	      * @param imgStr 图片Base64编码
	      * @param imgFilePath 保存图片全路径地址
	      * @return
	      * @创建时间 2017-06-19
	      */
	     public static boolean generateImage(String imgStr,String imgFilePath){
	         if (imgStr == null){ //图像数据为空
	             return false;
	         }
	         try 
	         {
	             //Base64解码
	             byte[] b = Base64.decodeBase64(imgStr);
	             for(int i=0;i<b.length;++i)
	             {
	            	//调整异常数据
	                 if(b[i]<0){
	                     b[i]+=256;
	                 }
	             }
	             //生成jpeg图片
	 
	             OutputStream out = new FileOutputStream(imgFilePath);    
	             out.write(b);
	             out.flush();
	             out.close();
	             return true;
	         } 
	         catch (Exception e) 
	         {
	             return false;
	         }
	     }
	     
	  // 将字CLOB转成STRING类型   
	     public static String ClobToString(Clob clob) throws Exception {   
	           
	         String reString = "";   
	         java.io.Reader is = clob.getCharacterStream();// 得到流   
	         BufferedReader br = new BufferedReader(is);   
	         String s = br.readLine();   
	         StringBuffer sb = new StringBuffer();   
	         while (s != null) {// 执行循环将字符串全部取出付值给StringBuffer由StringBuffer转成STRING   
	             sb.append(s);   
	             s = br.readLine();   
	         }   
	         reString = sb.toString();   
	         return reString;   
	     }
	     /**
	      * 将二维码图片拼装在素材右下角
	      * @param base64Img1 素材图片
	      * @param base64Img2 二维码图片
	      * @return
	      */
	     public static byte[] combinePicture(String base64Img1,String base64Img2){
	    	 ByteArrayInputStream bais = null;
	    	 OutputStream out = null;
	    	 try {
	    		BASE64Decoder decoder = new BASE64Decoder();
    	        byte[] bytes = decoder.decodeBuffer(base64Img1);
    	        bais = new ByteArrayInputStream(bytes);
    	        BufferedImage a = ImageIO.read(bais);
    	        
    	        a = setImgSize(a,BASE_WIDTH,BASE_HEIGHT);
    	        
    	        bytes = decoder.decodeBuffer(base64Img2);
    	        bais = new ByteArrayInputStream(bytes);
    	        BufferedImage b = ImageIO.read(bais);
    	        
    	        out = new ByteArrayOutputStream();
    	        writeImageLocal(out, modifyImagetogeter(b, a));
    	        
    	        bais = new ByteArrayInputStream(((ByteArrayOutputStream) out).toByteArray());
    	        byte[] bt = new byte[bais.available()];
    	        bais.read(bt);
    	        
    	        return bt;
    	        
			} catch (Exception e) {
				e.printStackTrace();
			}finally{
				if(bais != null){
					try {
						bais.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				if(out != null){
					try {
						out.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
	    	 
	    	 return null;
	     }
	    private static BufferedImage setImgSize(BufferedImage bi,int width,int height) {

	        BufferedImage newImage = new BufferedImage(width,height,bi.getType());

	        Graphics2D g = newImage.createGraphics();

	        g.drawImage(bi, 0,0,width,height,null);

	        g.dispose();

	        return newImage;
		}

		private static BufferedImage modifyImagetogeter(BufferedImage b, BufferedImage d) {  
	    	  
	         try {
	             int w = b.getWidth();  
	             int h = b.getHeight();
	             
	             Graphics2D g = d.createGraphics();  
	             //g.drawImage(b, 100, 20, w/4, h/4, null);
	             g.drawImage(b, 630, 380, CODE_WIDTH, CODE_HEIGHT, null);
	             g.dispose();  
	         } catch (Exception e) {  
	             System.out.println(e.getMessage());  
	         }  
	   
	         return d;  
	     }
	     
	     private static void writeImageLocal(OutputStream out, BufferedImage img) {  
	         if (out != null && img != null) {  
	             try {  
	                 //File outputfile = new File(newImage);  
	                 ImageIO.write(img, "jpg", out);
	                 /*File outputfile = new File("C:\\Users\\zc\\Desktop\\cc.jpg"); 
	                 ImageIO.write(img, "jpg", outputfile); */
	             } catch (IOException e) {
	            	 e.printStackTrace();
	                 System.out.println(e.getMessage());  
	             }  
	         }  
	     }
	     
}